package com.ruoyi.zhike.controller.merchant;

import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.MerchantMealInfo;
import com.ruoyi.zhike.merchant.service.IMerchantMealInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.MerchantMealInfoWrapper;

/**
 * 商户套餐信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/merchant/mealInfo")
public class MerchantMealInfoController extends BaseController
{
    @Autowired
    private IMerchantMealInfoService merchantMealInfoService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询商户套餐信息列表
     */
    @RequiresPermissions("merchant:mealInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(MerchantMealInfo merchantMealInfo)
    {
        startPage();
        List<Map<String, Object>> list = merchantMealInfoService.selectMerchantMealInfoListMap(merchantMealInfo);
        list = new MerchantMealInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户套餐信息列表
     */
    @RequiresPermissions("merchant:mealInfo:export")
    @Log(title = "商户套餐信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantMealInfo merchantMealInfo)
    {
        List<MerchantMealInfo> list = merchantMealInfoService.selectMerchantMealInfoList(merchantMealInfo);
        ExcelUtil<MerchantMealInfo> util = new ExcelUtil<MerchantMealInfo>(MerchantMealInfo.class);
        util.exportExcel(response, list, "商户套餐信息数据");
    }

    /**
     * 获取商户套餐信息详细信息
     */
    @RequiresPermissions("merchant:mealInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(merchantMealInfoService.selectMerchantMealInfoById(id));
    }

    /**
     * 新增商户套餐信息
     */
    @RequiresPermissions("merchant:mealInfo:add")
    @Log(title = "商户套餐信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantMealInfo merchantMealInfo)
    {
        return toAjax(merchantMealInfoService.insertMerchantMealInfo(merchantMealInfo));
    }

    /**
     * 修改商户套餐信息
     */
    @RequiresPermissions("merchant:mealInfo:edit")
    @Log(title = "商户套餐信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantMealInfo merchantMealInfo)
    {
        return toAjax(merchantMealInfoService.updateMerchantMealInfo(merchantMealInfo));
    }

    /**
     * 删除商户套餐信息
     */
    @RequiresPermissions("merchant:mealInfo:remove")
    @Log(title = "商户套餐信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merchantMealInfoService.deleteMerchantMealInfoByIds(ids));
    }
}
